﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TMIS.DAL
{
    public class OpenReport
    {
        private Model.ThesisDB db = new Model.ThesisDB();

        #region 更新开题报告表信息
        public void Update(Model.OpenReport openreport)
        {
            Model.OpenReport op = db.OpenReport.Single(e => e.ID == openreport.ID);
            op.Basis = openreport.Basis;
            op.Target = openreport.Target;
            op.Method = openreport.Method;
            op.Progress = openreport.Progress;
            op.Reference = openreport.Reference;
            db.SubmitChanges();
        }
        #endregion

        /// <summary>
        /// 获取ID号对应的开题报告
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public Model.OpenReport Get(Guid guid)
        {
            Model.OpenReport ope = (from o in db.OpenReport
                                    where o.ID == guid
                                    select o).FirstOrDefault();
            return ope;
        }
        /// <summary>
        /// 生成新的开题报告表
        /// </summary>
        /// <param name="openReport"></param>
        public void Insert(Model.OpenReport openReport)
        {
            db.OpenReport.InsertOnSubmit(openReport);
            db.SubmitChanges();
        }
    }
}
